#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
using namespace std;
#include <vector>

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<long long>> vv(n, vector<long long>(m, 0));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
            cin >> vv[i][j];
    }
    vector<long long> row(n, 0);
    vector<long long> col(m, 0);
    for (int i = 0; i < n; i++)
    {
        long long sum = 0;
        for (int j = 0; j < m; j++)
            sum += vv[i][j];
        row[i] = sum;
    }
    for (int i = 0; i < m; i++)
    {
        long long sum = 0;
        for (int j = 0; j < n; j++)
            sum += vv[j][i];
        col[i] = sum;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cout << row[i] + col[j] - vv[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

#include <iostream>
using namespace std;
#include <vector>

int main()
{
    int n, k;
    cin >> n >> k;
    vector<long long> a(n, 0);
    vector<long long> b(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    long long h = 0, s = 0;
    int left = 0, right = 0;
    int reti = 0;
    long long _h = 0, _s = 0;
    while (right < n)
    {
        //if(right-left<=k-1)
        //{
        h += a[right];
        s += b[right];

        //}
        while (right - left + 1 > k)
        {
            h -= a[left];
            s -= b[left];
            left++;
        }
        if (right - left == k - 1)
        {
            if (h > _h)
            {
                _h = h;
                _s = s;
                reti = left;
                //cout<<h<<":"<<s<<endl;
            }
            if (h == _h && s < _s)
            {
                _h = h;
                _s = s;
                reti = left;
                //cout<<h<<":"<<s<<endl;
            }

        }
        right++;
    }
    cout << reti + 1 << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main() {
    string s;
    cin >> s;
    int n;
    cin >> n;
    int left = 0, right = 0;
    int sum = 0;
    int _sum = 0;
    int reti = 0;
    while (right < s.size())
    {
        if (s[right] == 'C' || s[right] == 'G')
            sum++;
        if (right - left + 1 == n)
        {
            if (sum > _sum)
            {
                _sum = sum;
                reti = left;
            }
            if (s[left] == 'C' || s[left] == 'G')
                sum--;
            left++;
        }
        right++;
    }
    for (int i = reti; i < reti + n; i++)
    {
        cout << s[i];
    }
    return 0;
}